package 爬楼梯;

public class Solution {

    public static void main(String[] args) {
        Solution solution =  new Solution();

        System.out.println(solution.climbStairs(5));
        System.out.println(solution.climbStairs(45));
    }

    public int climbStairs(int n) {
        if(n == 1){
            return 1;
        }
        else if(n ==2){
            return 2;
        }
        int sum1 = 1;
        int sum2 = 2;
        int sum = 0;
        for (int i = 3; i <= n; i++) {
            sum = sum1 + sum2;
            sum1 = sum2;
            sum2 = sum;
        }
        return sum;

    }
}
